<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="/WEB-INF/c.tld"%>
<%@ taglib prefix="fn" uri="/WEB-INF/fn.tld"%>
<%@ taglib prefix="fmt" uri="/WEB-INF/fmt.tld"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">
		<title>My JSP 'list.jsp' starting page</title>
		<link rel="stylesheet" rev="stylesheet"
			href="<%=basePath%>css/Listing_Index.css" type="text/css">
		<link rel="stylesheet" rev="stylesheet"
			href="<%=basePath%>css/admin-v1.css" type="text/css">
	</head>
	<body>
		<div class="admin_right_title">
			<h1>
				发布售房信息
			</h1>
		</div>

		<dl class="adminSearch">
			<dt>
				搜索条件
			</dt>
			<dd>
				<label>
					区域：
				</label>
				<select name="searchzone" onchange="change(this)">
					<option value="">
						请选择
					</option>
					<c:forEach var="zone" items="${zoneList}">
						<option value="${zone.code}"
							<c:if test="${zone.code==home.zone}">selected</c:if>>
							${zone.name}
						</option>
					</c:forEach>
				</select>
				<label>
					装修：
				</label>
				<select name="searchfix" onchange="change(this)">
					<option value="">
						请选择
					</option>
					<c:forEach var="fix" items="${fixList}">
						<option value="${fix.code}"
							<c:if test="${fix.code==home.fix}">selected</c:if>>
							${fix.name}
						</option>
					</c:forEach>
				</select>
				<label>
					房型：
				</label>
				<select name="searchhouseType" onchange="change(this)">
					<option value="">
						请选择
					</option>
					<c:forEach var="houseType" items="${houseTypeList}">
						<option value="${houseType.code}"
							<c:if test="${houseType.code==home.houseType}">selected</c:if>>
							${houseType.name}
						</option>
					</c:forEach>
				</select>
				<label>
					房屋价格：
				</label>
				<select name="searchprice" onchange="change(this)">
					<option value="">
						请选择
					</option>
					<c:forEach var="price" items="${priceList}">
						<option value="${price.code}" <c:if test="${home.price==price.code}">selected</c:if>>
							${price.name}
						</option>
					</c:forEach>
				</select>
				<label>
					面积：
				</label>
				<select name="searcharea" onchange="change(this)">
					<option value="">
						请选择
					</option>
					<c:forEach var="area" items="${areaList}">
						<option value="${area.code}"
							<c:if test="${home.area==area.code}">selected</c:if>>
							${area.name}
						</option>
					</c:forEach>
				</select>
			</dd>
			<dd>
				<label>
					地址查询：
				</label>
				<input class="inputText_25_200" type="text" name="serachAddress"
					onblur="change(this)" />
				<input class="inputButton_25_80" id="home_type_btn" type="button"
					onclick="search()" value="查询" />
			</dd>
		</dl>

		<script>
			function change(obj){
				if(!obj){
					return ;
				}	
				if(obj.name=="searchzone"){
					document.getElementById("zone").value=obj.value;
					return ;
				}
				if(obj.name=="searchprice"){
					document.getElementById("price").value=obj.value;
					return ;
				}
				if(obj.name=="searchfix"){
					document.getElementById("fix").value=obj.value;
					return ;
				}
				if(obj.name=="searcharea"){
					document.getElementById("area").value=obj.value;
					return ;
				}
				
				if(obj.name=="searchhouseType"){
					document.getElementById("houseType").value=obj.value;
					return ;
				}
				if(obj.name="serachAddress"){
					document.getElementById("address").value=obj.value;
					return ;
				}		
			}
			function search(){
				if(typeof query =="function"){
					query();
				}
			}
		</script>
		<div class="opera_tools">
			<a href="<%=basePath%>/admin/sellhome/get.do">新增</a>
		</div>
		<ul class="house_gallery">
			<c:forEach var="home" items="${page.result}">
				<li>
					<div class="image_box">
						<c:choose>
							<c:when test="${home.smallIcon eq null || home.smallIcon eq ''}">
								<img src="<%=basePath%>images/default_image.gif" />
							</c:when>
							<c:otherwise>
								<img width="100" height="100"
									src="<%=basePath%>img/${home.smallIcon}" />
							</c:otherwise>
						</c:choose>
					</div>
					<dl class="search_list_info">
						<dd>
							<h1>
								<a href="<%=basePath%>/admin/sellhome/get.do?id=${home.id}">${home.name}</a>
							</h1>
						</dd>
						<dd>
							${home.address}
						</dd>
						<dd>
							<c:if test="${home.rentWay=='all'}">[整租]</c:if>
							<c:if test="${home.rentWay=='half'}">[合租]</c:if>
							面积：${home.area}平米，装修：${home.fix}，楼层：${home.floor}层
						</dd>
						<dd>
							<fmt:formatDate pattern="yyyy-MM-dd" value="${home.publishDate}" />

						</dd>
						<dd>
							<a href="<%=basePath%>/admin/sellhome/delete.do?id=${home.id}">删除</a>
						</dd>
					</dl>
					<div class="search_list_pay">
						<c:forEach var="type" items="${houseTypeList}">
							<c:if test="${home.houseType == type.code}">${type.name}</c:if>
						</c:forEach>
						<span class="search_list_money"> <strong>${home.price}元/月</strong>
						</span>
					</div>
					<div class="clear"></div>
				</li>
			</c:forEach>
		</ul>
		<form id="query" action="<%=basePath%>admin/sellhome/list.do"
			method="post">
			<input type="hidden" id="zone" name="zone" value="${home.zone}" />
			<input type="hidden" id="price" name="price" value="${home.price}" />
			<input type="hidden" id="fix" name="fix" value="${home.fix}" />
			<input type="hidden" id="area" name="area" value="${home.area}" />
			<input type="hidden" id="houseType" name="houseType"
				value="${home.houseType}" />
			<input type="hidden" id="address" />
			<c:if test="${page.totalPages>0}">
				<span>共${page.totalCount}条记录</span>
				<span>共${page.totalPages}页</span>
				<select name="currentPage" id="pageNo" onchange="query()">
					<c:forEach var="pageNo" begin="1" end="${page.totalPages}">
						<option value="${pageNo}" <c:if test="${pageNo==page.pageNo}">selected</c:if>>
							第${pageNo}页
						</option>
					</c:forEach>
				</select>
			</c:if>
		</form>
		<script>
				function query(){
					document.getElementById("query").submit();				
				}			
			</script>
	</body>
</html>
